@import './themes.scss';

// 获取HTML的data-theme值
@mixin themeify {
  @each $theme-name, $theme-map in $themes {
    //!global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    //判断html的data-theme的属性值  #{}是sass的插值表达式
    //& sass嵌套里的父容器标识   @content是混合器插槽，像vue的slot
    [data-theme='#{$theme-name}'] & {
      @content;
    }
  }
}
// 根据data-theme值及传过来的key去themes.scss里获取相应的颜色
// map-get($map,$key) 函数的作用是根据 $key 参数，返回 $key 在 $map 中对应的 value 值
@function themed($key) {
  @return map-get($theme-map, $key);
}

//获取背景颜色
@mixin background_color($color) {
  @include themeify {
    background-color: themed($color);
  }
}

@mixin background_color_imp2($color) {
  @include themeify {
    background-color: themed($color) !important;
  }
}

@mixin background($color) {
  @include themeify {
    background: themed($color);
  }
}

//获取字体颜色
@mixin font_color($color) {
  @include themeify {
    color: themed($color);
  }
}

//获取边框颜色
@mixin border($color) {
  @include themeify {
    border: themed($color);
  }
}

@mixin border_left($color) {
  @include themeify {
    border-left: themed($color);
  }
}

@mixin border_bottom($color) {
  @include themeify {
    border-bottom: themed($color);
  }
}

@mixin border_right($color) {
  @include themeify {
    border-right: themed($color);
  }
}

@mixin border_top($color) {
  @include themeify {
    border-top: themed($color);
  }
}

@mixin border_top2($color) {
  @include themeify {
    border-top: 1px solid themed($color);
  }
}

@mixin border_top_color($color) {
  @include themeify {
    border-top-color: themed($color);
  }
}

@mixin border_color($color) {
  @include themeify {
    border-color: themed($color);
  }
}

@mixin box_shadow($shadow) {
  @include themeify {
    box-shadow: themed($shadow);
  }
}

@mixin opacity($data) {
  @include themeify {
    opacity: themed($data);
  }
}

@mixin fill($color) {
  @include themeify {
    fill: themed($color);
  }
}
